package com.example.hxds.workflow.bpmn.comment;
import com.example.hxds.common.exception.HxdsException;
import com.example.hxds.workflow.db.dao.OrderCommentDao;
import java.util.HashMap;
import javax.annotation.Resource;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
 * @Author XUYANG
 * @Date 2024-04-10 15:34
 */
@Component
public class UpdateDataService implements JavaDelegate {
    @Resource
    private OrderCommentDao orderCommentDao;

    @Transactional(propagation = Propagation.REQUIRED)
    public void execute(DelegateExecution adeDelegateExecution) {
        long commentId = Long.parseLong((String)adeDelegateExecution.getVariable("commentId", String.class));
        HashMap<Object, Object> hashMap = new HashMap<>();
        hashMap.put("rate", Integer.valueOf(5));
        hashMap.put("remark", null);
        hashMap.put("commentId", Long.valueOf(commentId));
        if (this.orderCommentDao.updateRateAndRemark(hashMap) != 1){
            throw new HxdsException("更新订单评价分数和文字内容失败");
        }
        System.out.println("更新数据");
    }
}
